'''
Notice that "every second child will be removed".
So there is no need to simulate the process.
Instead, we discuss the following two circumstances:

if n is even:
    if k <= n/2:
        print(2*k)
    else:
        print(2*k-(n+1))
else:
    if k <= n/2:
        print(2*n)
    else:
        print(2*k-n)
'''
tc = int(input())
for _t in range(tc):
    n, k = map(int, input().strip().split(' '))
    if k <= n//2:
        print(2*k)
    else:
        if n % 2: # odd
            print(2*k-n)
        else:
            print(2*k-(n+1))
